# Include all custom CHE_* properties that user may has defined in its che.env file
<% ENV.each do |k,v| -%>
<% if k.include? "CHE_" then  -%>
<%= k + '=' + v %>
<% end -%>
<% end -%>


CHE_IP=<%= scope.lookupvar('che::che_ip') %>
CHE_PORT=<%= scope.lookupvar('che::che_port') %>
#DOCKER_HOST=<%= scope.lookupvar('che::docker_host') %>
#DOCKER_MACHINE_HOST=<%= scope.lookupvar('che::docker_ip') %>

<% if @che_jmx_enabled == "true" -%>
CATALINA_OPTS=-Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/conf/jmxremote.access -Dcom.sun.management.jmxremote.ssl=false
<% end -%>

<% if scope.lookupvar('che::che_env') != "production" -%>
CHE_DEBUG_SERVER=true
JPDA=jpda
CHE_ASSEMBLY=<%= scope.lookupvar('che::che_assembly') %>
JPDA_ADDRESS=<%= scope.lookupvar('che::che_debug_port') %>
<% if scope.lookupvar('che::che_debug_suspend') == "true" %>JPDA_SUSPEND=y<% end %>
<% end -%>

<% if scope.lookupvar('che::che_multiuser') == 'true' -%>
CHE_DOCKER_NETWORK=che_che-network
<% else -%>
CHE_DOCKER_NETWORK=bridge
<% end -%>
CHE_DATABASE=/data
CHE_WORKSPACE_STORAGE=/data/workspaces
CHE_LOGS_DIR=/logs
CHE_WORKSPACE_LOGS=/logs/machines
CHE_TEMPLATE_STORAGE=/data/templates
CHE_LOCAL_CONF_DIR=/conf/

CHE_WORKSPACE_TERMINAL__LINUX__AMD64=<%= scope.lookupvar('che::che_instance') %>/data/lib/linux_amd64/terminal
CHE_WORKSPACE_TERMINAL__LINUX__ARM7=<%= scope.lookupvar('che::che_instance') %>/data/lib/linux_arm7/terminal
CHE_WORKSPACE_AGENT_DEV=<%= scope.lookupvar('che::che_instance') %>/data/lib/ws-agent.tar.gz

<% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%>
JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true
<% end -%>
<% if ! @che_http_proxy.empty? -%>
<% if ! @che_http_proxy.empty? and @che_http_proxy.include? '@' -%>
JAVA_HTTP_USER_NAME=-Dhttp.proxyUser=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %>
JAVA_HTTP_USER_PASSWORD=-Dhttp.proxyPassword=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %>
JAVA_HTTP_PROXY_HOST=-Dhttp.proxyHost=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %>
JAVA_HTTP_PROXY_PORT=-Dhttp.proxyPort=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %>
<% else -%>
JAVA_HTTP_PROXY_HOST=-Dhttp.proxyHost=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %>
JAVA_HTTP_PROXY_PORT=-Dhttp.proxyPort=<%= @che_http_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %>
<% end -%>
<% end -%>
<% if ! @che_https_proxy.empty? -%>
<% if @che_https_proxy.include? '@' -%>
JAVA_HTTPS_USER_NAME=-Dhttps.proxyUser=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %>
JAVA_HTTPS_USER_PASSWORD=-Dhttps.proxyPassword=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %>
JAVA_HTTPS_PROXY_HOST=-Dhttps.proxyHost=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %>
JAVA_HTTPS_PROXY_PORT=-Dhttps.proxyPort=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %>
<% else -%>
JAVA_HTTPS_PROXY_HOST=-Dhttps.proxyHost=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %>
JAVA_HTTPS_PROXY_PORT=-Dhttps.proxyPort=<%= @che_https_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %>
<% end -%>
<% end -%>
<% if ! @che_no_proxy.empty? -%>
JAVA_NO_PROXY=-Dhttp.nonProxyHosts='<%= @che_no_proxy.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(",").uniq.join("|") %>|'
<% end -%>
JAVA_OPTS=-Xms512m -Xmx<%= @che_server_xmx %>m -Djava.security.egd=file:/dev/./urandom -server -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark -Dche.local.conf.dir=${CHE_LOCAL_CONF_DIR} <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%>$JAVA_HTTP_PROXY_SET<% end -%> <% if ! @che_http_proxy.empty? -%>$JAVA_HTTP_PROXY_HOST $JAVA_HTTP_PROXY_PORT<% end -%> <% if ! @che_https_proxy.empty? -%>$JAVA_HTTPS_PROXY_HOST $JAVA_HTTPS_PROXY_PORT<% end -%><%- if ! @che_no_proxy.empty? -%> $JAVA_NO_PROXY<% end -%><% if @che_http_proxy.include? '@' -%> $JAVA_HTTP_USER_NAME $JAVA_HTTP_USER_PASSWORD<% end -%><% if @che_https_proxy.include? '@' -%> $JAVA_HTTPS_USER_NAME $JAVA_HTTPS_USER_PASSWORD<% end %>

# java opts for ws agent
CHE_WORKSPACE_JAVA_OPTIONS=<%= scope.lookupvar('che::workspace_java_options') %> <% if ! @http_proxy_for_che_workspaces.empty? or ! @https_proxy_for_che_workspaces.empty? -%>-Dhttp.proxySet=true<% end -%><% if ! @http_proxy_for_che_workspaces.empty? -%><% if ! @http_proxy_for_che_workspaces.empty? and @http_proxy_for_che_workspaces.include? '@' -%> -Dhttp.proxyUser=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttp.proxyPassword=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @https_proxy_for_che_workspaces.empty? -%><% if @https_proxy_for_che_workspaces.include? '@' -%> -Dhttps.proxyUser=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttps.proxyPassword=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @che_no_proxy.empty? -%> -Dhttp.nonProxyHosts='<%= @no_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(",").uniq.join("|") %>|'<% end -%>

# Enable single port options
<% if scope.lookupvar('che::che_single_port') == "true" -%>
CHE_DOCKER_SERVER__EVALUATION__STRATEGY=custom
CHE_PLUGIN_TRAEFIK_ENABLED=true
<% end -%>
